package com.cs.study.homework._0311.TestTCP3;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {
        //1. 创建客户端Socket对象
        Socket socket = new Socket("192.168.106.110", 4567);
        //2. 从socket中获取输入输出流
        InputStream in = socket.getInputStream();
        //3. 利用输出输出流进行读写操作
        FileInputStream fileInputStream = new FileInputStream("E://a//a.txt");
        OutputStream out = socket.getOutputStream();
        int readCount;
        byte[] bytes = new byte[1024];
        while ((readCount = fileInputStream.read()) != -1) {
            out.write(bytes, 0, readCount);
        }

        //4. 释放资源close
        in.close();
        socket.close();
    }
}

